<extend name="./Apps/Home/View/default/shops/layout.html" />
<block name="content">
<style>
.ATRoot{height:22px;line-height:22px;margin-left:5px;clear:both;cursor:pointer;}
.ATNode{margin-left:5px;line-height:22px;margin-left:17px;clear:both;cursor:pointer;}
.Hide{display:none;}
dl.areaSelect{padding:0 5px; display: inline-block; width:100%; margin-bottom: 0;/*border:1px solid #eee;*/}
dl.areaSelect:hover{border:1px solid #E5CD29;}
dl.areaSelect:hover dd{display: block;}
dl.areaSelect dd{ float: left; margin-left: 20px; cursor: pointer;}
</style>

<script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
<script src="__PUBLIC__/plugins/kindeditor/lang/zh-CN.js"></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=37f0869604ca86505487639427d52bf6"></script>

<script>
var relateCommunity = "{$object['relateCommunity']}".split(',');
var relateArea = "{$object['relateArea']}".split(',');
var areaId = '{$object['areaId2']}';
var shopMap = null;
var toolBar = null;
$(function () {
	   //展开按钮
	   $("#expendAll").click(function(){
			if ($(this).prop('checked')==true) {$("dl.areaSelect dd").removeClass('Hide')}
			else{$("dl.areaSelect dd").addClass('Hide')}
	   });
	   $("input[name='isDistributAll']").click(function(){
		   if($(this).val()==1){
			   $("#delivery_tr").hide();
		   }else{
			   $("#delivery_tr").show();
		   }
	   });
	   $.formValidator.initConfig({
		   theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
			   editShop();
			   return false;
			},onError:function(msg){
		}});
	    $("#shopName").formValidator({onShow:"",onFocus:"店铺名称不能超过20个字符",onCorrect:"输入正确"}).inputValidator({min:1,max:20,onError:"店铺名称不符合要求,请确认"});
		$("#userName").formValidator({onShow:"",onFocus:"请输入店主姓名",onCorrect:"输入正确"}).inputValidator({min:1,max:20,onError:"店主姓名不能为空,请确认"});
		$("#shopCompany").formValidator({onShow:"",onFocus:"请输入公司名称",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"公司名称不能为空,请确认"});
		$("#shopTel").formValidator({onShow:"",onFocus:"请输入店铺电话",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"店铺电话不能为空,请确认"});
		$("#shopAddress").formValidator({onShow:"",onFocus:"请输入公司地址",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"公司地址不能为空,请确认"});
		$("#bankNo").formValidator({onShow:"",onFocus:"请输入银行卡号",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"银行卡号不能为空,请确认"});
		$("#bankUserName").formValidator({onShow:"",onFocus:"请输入银行卡所有人名称",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"银行卡号所有人名称不能为空,请确认"});
		$("#deliveryStartMoney").formValidator({onShow:"",onFocus:"请输入订单配送起步价",onCorrect:"输入正确"});
		$("#deliveryFreeMoney").formValidator({onShow:"",onFocus:"请输入包邮起步价",onCorrect:"输入正确"});
		$("#deliveryMoney").formValidator({onShow:"",onFocus:"请输入邮费",onCorrect:"输入正确"});
		$("#deliveryCostTime").formValidator({onShow:"",onFocus:"请输入平均配送时间",onCorrect:"输入正确"});
		$("#avgeCostMoney").formValidator({onShow:"",onFocus:"请输入平均消费金额",onCorrect:"输入正确"});
		
		getCommunitysForShopEdit();
		initTime('serviceStartTime','{$object['serviceStartTime']}');
		initTime('serviceEndTime','{$object['serviceEndTime']}');
		var uploading = null;
		uploadFile({
	    	  server:Think.U('Home/Shops/uploadPic'),pick:'#filePicker',
	    	  formData: {dir:'shops'},
	    	  accept: {
	    	        title: 'Images',
	    	        extensions: 'gif,jpg,jpeg,png',
	    	        mimeTypes: 'image/*'
	    	  },
	    	  callback:function(f){
	    		  layer.close(uploading);
	    		  var json = WST.toJson(f);
	    		  $('#preview').attr('src',WST.DOMAIN+"/"+json.file.savepath+json.file.savethumbname);
	    		  $('#shopImg').val(json.file.savepath+json.file.savename);
	    		  $('#preview').show();
		      },
		      progress:function(rate){
		    	  uploading = WST.msg('正在上传图片，请稍后...');
		      }
	    });
		ShopMapInit();
});
function ShopMapInit(option){
	   var opts = {zoom:$('#mapLevel').val(),longitude:$('#longitude').val(),latitude:$('#latitude').val()};
	   if(shopMap)return;
	   $('#shopMap').show();
	   shopMap = new AMap.Map('mapContainer', {
			view: new AMap.View2D({
				zoom:opts.zoom
			})
	   });
	   if(opts.longitude!='' && opts.latitude){
		   shopMap.setZoomAndCenter(opts.zoom, new AMap.LngLat(opts.longitude, opts.latitude));
		   var marker = new AMap.Marker({
				position: new AMap.LngLat(opts.longitude, opts.latitude), //基点位置
				icon:"http://webapi.amap.com/images/marker_sprite.png"
		   });
		   marker.setMap(shopMap);
	   }
	   shopMap.plugin(["AMap.ToolBar"],function(){		
			toolBar = new AMap.ToolBar();
			shopMap.addControl(toolBar);		
	   });
	   toolBar.show();
}
</script>
   <div class="wst-body"> 
       <div class='wst-page-header'>卖家中心 > 店铺资料</div>
       <div class='wst-page-content' style="position:relative;">
       <form name="myform" method="post" id="myform" autocomplete="off">
        <input type='hidden' id='id' value='{$object.shopId}'/>
        <input type='hidden' id='shopImg' value='{$object.shopImg}'/>
        <table class="table table-hover table-striped table-bordered wst-form">
           <tr>
             <th width='150' align='right'>店铺名称<font color='red'>*</font>：</th>
             <td><input type='text' id='shopName' class="form-control wst-ipt" value='{$object.shopName}' style='width:250px;' maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>店主姓名<font color='red'>*</font>：</th>
             <td><input type='text' id='userName' class="form-control wst-ipt" value='{$object.userName}' style='width:250px;' maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>公司名称<font color='red'>*</font>：</th>
             <td><input type='text' id='shopCompany' class="form-control wst-ipt" value='{$object.shopCompany}' style='width:250px;' maxLength='25'/></td>
           </tr>
           <tr style="height:80px;">
             <th align='right'>店铺图标<font color='red'>*</font>：</th>
             <td>
	           <div>
             	    <div id="filePicker" style='margin-left:0px;float:left'>上传店铺图标</div>
             	    <div style='margin-left:5px;float:left'>图片大小:150 x 150 (px)，格式为 gif, jpg, jpeg, png</div>
             	</div>
             	<div style='clear:both;'>
	             	<if condition="$object['shopImg'] !='' ">
	             		<img height="100" id='preview' class='lazyImg' data-original='__ROOT__/{$object.shopImg}'>
	             	</if>
	             </div>
             </td>
           </tr>
           
           <tr>
             <th align='right'>店铺电话<font color='red'>*</font>：</th>
             <td><input type='text' id='shopTel' class="form-control wst-ipt" value='{$object.shopTel}' maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>QQ：</th>
             <td><input type='text' id='qqNo' class="form-control wst-ipt" value='{$object.qqNo}' maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>店铺地址<font color='red'>*</font>：</th>
             <td><input type='text' id='shopAddress' class="form-control wst-ipt" value='{$object.shopAddress}' style='width:350px;' maxLength='100'/></td>
           </tr>
           <tr id='shopMap'>
             <td>&nbsp;</td>
             <td>
             <div id="mapContainer" style='height:400px;width:90%;'>等待地图初始化...</div>
             <div >
             <input type='hidden' id='latitude' name='latitude' value="{$object['latitude']}"/>
             <input type='hidden' id='longitude' name='longitude' value="{$object['longitude']}"/>
             <input type='hidden' id='mapLevel' name='mapLevel' value="{$object['mapLevel']}"/>
             </div>
             </td>
           </tr>
          
           <tr>
             <th align='right'>营业状态<font color='red'>*</font>：</th>
             <td>
             <label>
             <input type='radio' name='shopAtive' value='1' <if condition="$object['shopAtive'] ==1 ">checked</if> />营业中&nbsp;&nbsp;
             </label>
             <label>
             <input type='radio' name='shopAtive' value='0' <if condition="$object['shopAtive'] ==0 ">checked</if> />休息中
             </label>
             </td>
           </tr>
           <tr>
             <th align='right'>配送范围<font color='red'>*</font>：</th>
             <td>
             <label>
             <input type='radio' name='isDistributAll' value='0' <if condition="$object['isDistributAll'] ==0 ">checked</if> />区域配送&nbsp;&nbsp;
             </label>
             <label>
             <input type='radio' name='isDistributAll' value='1' <if condition="$object['isDistributAll'] ==1 ">checked</if> />全国配送
             </label>
             </td>
           </tr>
           <tr id="delivery_tr" style="display: {$object['isDistributAll'] ==1?'none':''}">
             <th align='right'>配送区域<font color='red'>*</font>：</th>
             <td id="wst_shop_area">
             <div class="text-gray Hide">展开全部：<input type="checkbox" id="expendAll" checked <if condition="$WST_USER['isSelf'] == 1">disabled</if> ></div>
             <div id='areaTree'></div>
             </td>
           </tr>
           <tr>
             <th align='right'>订单配送起步价(元)<font color='red'>*</font>：</th>
             <td><input type='text' id='deliveryStartMoney' class="form-control wst-ipt" value='{$object.deliveryStartMoney}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='6'/></td>
           </tr>
           <tr>
             <th align='right'>包邮起步价(元)<font color='red'>*</font>：</th>
             <td><input type='text' id='deliveryFreeMoney' class="form-control wst-ipt" value='{$object.deliveryFreeMoney}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='6'/></td>
           </tr>
           <tr>
             <th align='right'>邮费(元)<font color='red'>*</font>：</th>
             <td><input type='text' id='deliveryMoney' class="form-control wst-ipt" value='{$object.deliveryMoney}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>平均配送时间(分钟)<font color='red'>*</font>：</th>
             <td><input type='text' id='deliveryCostTime' class="form-control wst-ipt" value='{$object.deliveryCostTime}' onkeypress="return WST.isNumberKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='6'/></td>
           </tr>
           <tr>
             <th align='right'>平均消费金额(元)<font color='red'>*</font>：</th>
             <td><input type='text' id='avgeCostMoney' class="form-control wst-ipt" value='{$object.avgeCostMoney}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='25'/></td>
           </tr>
           <tr>
             <th align='right'>能否开发票<font color='red'>*</font>：</th>
             <td>
             <label>
             <input type='radio' id='isInvoice1' name='isInvoice' value='1' onclick='javascript:isInvoce(true)' <if condition="$object['isInvoice'] ==1 ">checked</if> />能&nbsp;&nbsp;
             </label>
             <label>
             <input type='radio' id='isInvoice0' name='isInvoice' value='0' onclick='javascript:isInvoce(false)' <if condition="$object['isInvoice'] ==0 ">checked</if> />否
             </label>
             </td>
           </tr>
           <tr id='invoiceRemarkstr' <if condition="$object['isInvoice'] ==0 ">style='display:none'</if>>
             <th align='right'>发票说明：</th>
             <td><input type='text' id='invoiceRemarks' class="form-control wst-ipt" value='{$object.invoiceRemarks}' style='width:350px;' maxLength='100'/></td>
           </tr>
           <tr>
             <th width='120' align='right'>转账银行<font color='red'>*</font>：</th>
             <td>
             <select id='bankId'>
                <option value=''>请选择</option>
                <volist name="bankList" id="vo">
                <option <if condition="$vo['bankId'] eq $object['bankId']">selected</if> value='{$vo['bankId']}'>{$vo['bankName']}</option>
                </volist>
             </select>
             </td>
           </tr>
           <tr>
             <th width='120' align='right'>银行卡卡号<font color='red'>*</font>：</th>
             <td><input type='text' id='bankNo' value='{$object.bankNo}' maxLength='25' size='50'/></td>
           </tr>
           <tr>
             <th width='120' align='right'>银行卡所有人名称<font color='red'>*</font>：</th>
             <td><input type='text' id='bankUserName' value='{$object.bankUserName}' maxLength='25' size='50'/></td>
           </tr>
           <tr>
             <th align='right'>营业时间<font color='red'>*</font>：</th>
             <td>
             <select id='serviceStartTime'>
                <option>请选择</option>
             </select>
             至
             <select id='serviceEndTime'>
                <option>请选择</option>
             </select>
             </td>
           </tr>
           <tr>
             <td colspan='2' style='text-align:center;padding:20px;'>
                 <button type="submit" class='wst-btn-query'>保&nbsp;存</button>&nbsp;&nbsp;
                 <button type="button" class='wst-btn-query' onclick='javascript:location.reload();'>重&nbsp;置</button>
             	
             </td>
           </tr>
        </table>
       </form>
       </div>
   </div>
   <script type="text/javascript">
   var isSelf = "{$WST_USER['isSelf']}"; 
	</script>
</block>  
